package com.kinyx.framework;

import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;

import javax.util.XArrayList;
import javax.util.XHashMap;

import com.kinyx.framework.file.KI18NUtils;
import com.kinyx.framework.file.KPropertiesReader;

public interface Configs {

	/** 配置属性 */
	Properties PROPERTIES = KPropertiesReader.read("configs.properties");

	/** 框架调试状态 */
	boolean FRAMEWORK_DEBUG = KPropertiesReader.getBooleanValue(PROPERTIES, "framework.debug", false);

	/** 默认值：国际化 */
	Locale default_locale = KI18NUtils.locale(KPropertiesReader.getStringValue(PROPERTIES, "default.locale", "zh_CN"));

	/** 默认值：真值列表 */
	List<String> default_trues = KPropertiesReader.getListValue(PROPERTIES, "default.trues", new XArrayList<String>().xAdd("1").xAdd("true").xAdd("T").xAdd("YES").xAdd("Y"), null);
	/** 默认值：假值列表 */
	List<String> default_falses = KPropertiesReader.getListValue(PROPERTIES, "default.falses", new XArrayList<String>().xAdd("").xAdd("0").xAdd("false").xAdd("F").xAdd("NO").xAdd("N"), null);

	/** 默认值：字符集 */
	String default_KReader_charset = KPropertiesReader.getStringValue(PROPERTIES, "default.KReader.charset", "UTF-8");
	/** 默认值：字符集 */
	String default_KFileWriter_charset = KPropertiesReader.getStringValue(PROPERTIES, "default.KFileWriter.charset", "UTF-8");
	/** 默认值：字符集 */
	String default_KImageUtils_charset = KPropertiesReader.getStringValue(PROPERTIES, "default.KImageUtils.charset", "UTF-8");
	/** 默认值：字符集 */
	String default_KBase64_charset = KPropertiesReader.getStringValue(PROPERTIES, "default.KBase64.charset", "UTF-8");
	/** 默认值：字符集 */
	String default_MD5_charset = KPropertiesReader.getStringValue(PROPERTIES, "default.MD5.charset", "UTF-8");
	/** 默认值：字符集 */
	String default_RSA_charset = KPropertiesReader.getStringValue(PROPERTIES, "default.RSA.charset", "UTF-8");
	/** 默认值：日期格式模板 */
	String default_KCalendarUtils_datePattern = KPropertiesReader.getStringValue(PROPERTIES, "default.KCalendarUtils.datePattern", "yyyyMMdd");
	/** 默认值：日期格式模板 */
	String default_KDateTimeUtils_timePattern = KPropertiesReader.getStringValue(PROPERTIES, "default.KDateTimeUtils.timePattern", "yyyyMMddHHmmssSSS");

	/** 默认值：页面大小 */
	Integer default_pageSize = KPropertiesReader.getIntegerValue(PROPERTIES, "default.pageSize", 25);

	/** 类型转换器实现类包名 */
	String TypeConvertPackageName = KPropertiesReader.getStringValue(PROPERTIES, "TypeConvertPackageName", "com.kinyx.framework.TypeConvert");

	/** 文件服务器：根地址 */
	String fileServer_rootUrl = KPropertiesReader.getStringValue(PROPERTIES, "fileServer.rootUrl", "http://file.kinyx.com");
	/** 文件服务器：根路径 */
	String fileServer_rootPath = KPropertiesReader.getStringValue(PROPERTIES, "fileServer.rootPath", "/file");

	/** 根 */
	String ROOT = "ROOT";

	/** 特殊分隔符 */
	String specialSeparator = KPropertiesReader.getStringValue(PROPERTIES, "specialSeparator", "#@#");

	/** HTML转义符号 */
	Map<String, String> HTML_SYMBOLS = new XHashMap<>(KPropertiesReader.getMapValue(PROPERTIES, "HTML.SYMBOLS", new HashMap<String, String>(), "|", "="))//
			.xPut(" ", "&nbsp;")//
			.xPut("<", "&lt;")//
			.xPut(">", "&gt;")//
			.xPut("$", "&#36;")//
			.xPut("&", "&amp;")//
			.xPut("'", "&#039;")//
			.xPut("\"", "&quot;")//
			.xPut("@", "&#64;")//
			.xPut("®", "&reg;")//
			.xPut("©", "&copy;")//
			.xPut("×", "&times;")//
			.xPut("÷", "&divide;")//
	;

}
